package com.myproject.thread;

import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

public class DoubleJoin1 {

    public static Map map = new HashMap<String,Thread>();

    public static void main(String[] args) throws InterruptedException {

        ExecutorService service = Executors.newFixedThreadPool(5);
        Thread.interrupted();

        Thread t1 = new Thread(new Runnable() {
            @Override
            public void run() {
                System.out.println("t1 start");
                Thread t2 = (Thread) map.get("t2");
                try {
                    t2.join();
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
                System.out.println("t1 over");
            }
        });
        Thread t2 = new Thread(new Runnable() {
            @Override
            public void run() {
                System.out.println("t2 start");
                System.out.println("t2 over");
            }
        });
        map.put("t1",t1);
        map.put("t2",t2);
        t1.start();
        //t2.start();

        Thread.sleep(1000);
        System.out.println(t1.getState().toString());
        System.out.println(t2.getState().toString());
    }

}
